use "${clean}analysis.dta", clear

keep if south == 1 
drop if congress > 55

// keeping only democrats
keep if partyid == 0

//standardizing variables
egen birth_county_surban = std(birth_county_urban_percent)
egen birth_county_srugged = std(birth_county_ruggedness)
egen birth_county_spostoffice = std(birth_county_postoffice_area)
egen sborn = std(born)

// creating a variable to keep the sample constant
cap drop sample
gen sample = 1
foreach var of varlist $county_bcontrols $life_controls {
	replace sample = . if `var' == .
}
keep if sample == 1

// collapsing
collapse singular (count) weight = singular, by(year)

cap drop weight_bubble
gen weight_bubble = .
replace weight_bubble = 1 if weight >= 1 & weight <= 14
replace weight_bubble = 2 if weight > 14 & weight <= 30
replace weight_bubble = 3 if weight > 30 & weight <= 50
replace weight_bubble = 4 if weight > 50 & weight <= 80
replace weight_bubble = 5 if weight > 80

twoway ///
	(scatteri 1 1865.5 1 1876, fcolor("${orange}") finten(inten10) recast(area)) ///
	(scatteri 1 1860.5 1 1865.5, fcolor("${orange}") finten(inten50) recast(area)) ///
	(scatter singular year if weight_bubble == 1,  mcolor("${red}") msym(Oh) msize(small) ) ///
	(scatter singular year if weight_bubble == 2,  mcolor("${red}") msym(Oh) msize(medium) ) ///
	(scatter singular year if weight_bubble == 3,  mcolor("${red}") msym(Oh) msize(vlarge) ) ///
	(scatter singular year if weight_bubble == 4,  mcolor("${red}") msym(Oh) msize(huge) ) ///
	(scatter singular year if weight_bubble == 5,  mcolor("${red}") msym(Oh) msize(ehuge) ) ///
	(lfit singular year if year <= 1860 [aw = weight], lwidth(thick) lpattern(dash) lcolor("${red}")) ///
	(lfit singular year if year > 1861 [aw = weight], lwidth(thick) lpattern(dash) lcolor("${red}")) ///
	, legend(ring(0) pos(5) row(5) order(3 "2-3" 4 "15-29" 5 "38-48" 6 "54-78" 7 "121") region(lcolor(gs1))) ///
	subtitle("Southern Democrats", box bexpand bcolor(gs2) color(white) size(large) ) ///
	xlab(1852(4)1900) ///
	xtitle("Year of Congress") ///
	ytitle("Prop. Singular") ///
	text(.95 1870.5 "Reconstruction", size(medsmall)) ///
	text(.95 1863 "Civil", size(medsmall)) ///
	text(.90 1863 "War", size(medsmall))
graph export "${output}FigS11_congress_southdem_bubbles.pdf", as(pdf) replace


	
	
	
	
	
	
	
	
